#ifndef _ST7305_UI_H_
#define _ST7305_UI_H_
#include "esp_err.h"

#define value_interchange(a, b)                                                     \
  (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b))) ///< No-temp-var swap operation

#ifdef __cplusplus
extern "C" {
#endif

class ST7305_UI{
public:
  ST7305_UI(uint16_t w, uint16_t h, uint8_t rotation = 0);
  ~ST7305_UI();

  virtual void writePoint(uint16_t x, uint16_t y, bool enabled);
  virtual void writePoint(uint16_t x, uint16_t y, uint8_t color);

  void drawPixel(uint16_t x, uint16_t y, bool enabled);
  void drawPixel(uint16_t x, uint16_t y, uint8_t color);

  void drawFastHLine(uint16_t x, uint16_t y, uint16_t len, uint8_t color);
  void drawFastVLine(uint16_t x, uint16_t y, uint16_t len, uint8_t color);

  // 画直线
  void drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);

  // 画三角形
  void drawTriangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint8_t color);

  // 画实心三角形
  void drawFilledTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color);

  // 画矩形
  void drawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color);

  // 画实心矩形
  void drawFilledRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t color);

  // 画圆形
  void drawCircle(uint16_t xc, uint16_t yc, uint16_t r, uint8_t  color);

  // 画实心圆形
  void drawFilledCircle(uint16_t centerX, uint16_t centerY, uint16_t radius, uint8_t  color);

  // 画多边形
  void drawPolygon(uint16_t* points, uint16_t n, uint8_t  color);

  // 画实心多边形
  void drawFilledPolygon(uint16_t* points, uint16_t n, uint8_t  color);

  void setRotation(uint8_t r);
  void drawXBM(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t* xbmData);
private:
  uint8_t WIDTH;
  uint8_t HEIGHT;
  uint8_t Rotation;
};




esp_err_t ydp_tft_154_init(void);

#ifdef __cplusplus
}
#endif

#endif